#
#  Copyright (c) 2010 RICOH Co. Ltd. All rights reserved.
#
NOPROFILE=
NOMAN=
NOLINT=

NCSTOPDIR=	../../../../..
TOPDIR=		$(NCSTOPDIR)/..

.if exists($(NCSTOPDIR)/Makefile.inc)
.include "$(NCSTOPDIR)/Makefile.inc"
.endif
.if exists($(NCSTOPDIR)/Makefile.warn)
.include "${NCSTOPDIR}/Makefile.warn"
.endif
.if exists($(NCSTOPDIR)/Makefile.conf)
.include "$(NCSTOPDIR)/Makefile.conf"
.endif

MFP=
CFLAGS+= -DRICOH_SPEC_MFP=1
CFLAGS+= -DRICOH_SPEC_GW=1
CFLAGS+= -DSMBCD_MFPRINT_USE=1
CFLAGS+= -DRICOH_SPEC_IPV6=1

LLMNR=
CFLAGS+= -DRICOH_SPEC_LLMNR=1

WSD=
CFLAGS+= -DRICOH_SPEC_WSD=1

CFLAGS+= -DRICOH_SPEC_LPUX20=1

.if defined(SMBCD_KERBEROS_SUPPORT)
CFLAGS+= -DRICOH_SPEC_KERBEROS=1
.endif

DIR_SMBCD_ROOT=		..
DIR_GWCOMMON=		$(DIR_SMBCD_ROOT)/gwcommon
DIR_GWCOMMON_GW=	$(TOPDIR)/gwcommon
DIR_SAMBA=			$(DIR_SMBCD_ROOT)/smbcd/samba
DIR_SRC=			$(DIR_SMBCD_ROOT)/smbcd/src
DIR_LIBLLMNR=		$(NCSTOPDIR)/nai/src/libllmnr
DIR_LIBWSD=		$(NCSTOPDIR)/nai/src/libwsd

.PATH:	$(DIR_SMBCD_ROOT) \
		$(DIR_SAMBA) \
		$(DIR_SAMBA)/intl \
		$(DIR_SAMBA)/lib \
		$(DIR_SAMBA)/lib/replace \
		$(DIR_SAMBA)/lib/talloc \
		$(DIR_SAMBA)/libads \
		$(DIR_SAMBA)/libsmb \
		$(DIR_SAMBA)/param \
		$(DIR_SAMBA)/passdb \
		$(DIR_SAMBA)/rpc_client \
		$(DIR_SAMBA)/rpc_parse \
		$(DIR_SAMBA)/tdb/common \
		$(DIR_SRC)

CFLAGS+= -g -w

CFLAGS+= -DBINDIR=\"\"
CFLAGS+= -DCONFIGFILE=\"/udom/smb.conf\"
CFLAGS+= -DLIBDIR=\"\"
CFLAGS+= -DLMHOSTSFILE=\"\"
CFLAGS+= -DLOCKDIR=\".\"
CFLAGS+= -DLOGFILEBASE=\"\"
CFLAGS+= -DPIDDIR=\"\"
CFLAGS+= -DPRIVATE_DIR=\"\"
CFLAGS+= -DSBINDIR=\"\"
CFLAGS+= -DSMB_PASSWD_FILE=\"\"
CFLAGS+= -DSWATDIR=\"\"

CFLAGS+= -I$(DIR_SAMBA)
CFLAGS+= -I$(DIR_SAMBA)/include
CFLAGS+= -I$(DIR_SAMBA)/lib/replace
CFLAGS+= -I$(DIR_SAMBA)/lib/talloc
CFLAGS+= -I$(DIR_SAMBA)/librpc
CFLAGS+= -I$(DIR_SAMBA)/popt
CFLAGS+= -I$(DIR_SAMBA)/tdb/include
CFLAGS+= -I$(DIR_SRC)
CFLAGS+= -I$(NCS_TOP_INC_DIR)
CFLAGS+= -I$(DIR_GWCOMMON_GW)/inc
CFLAGS+= -I$(DIR_GWCOMMON_GW)/inc/if
CFLAGS+= -I$(MACHINEDEF_INC_DIR)

.if defined(SMBCD_KERBEROS_SUPPORT)
CFLAGS+= -I /usr/include/krb5
.endif
.if defined(LLMNR)
CFLAGS+= -I$(DIR_LIBLLMNR)/include
.endif
.if defined(WSD)
CFLAGS+= -I$(DIR_LIBWSD)/include
.endif

CFLAGS+= -I${TOPDIR}/gwpf_base/destdir/usr/include
CFLAGS+= -I${TOPDIR}/gwpf_base/destdir/gwipc/include/libgwipc

PROG=		smbcd.tmp
INSTALL=	install -c

SRCS+= smbc_iconv.c
SRCS+= smbc_if_NcsSmbGetFolderList.c
SRCS+= smbc_if_NcsSmbUserAuth.c
SRCS+= smbc_ipv6.c
SRCS+= smbc_lib.c
SRCS+= smbc_local.c
SRCS+= smbc_log.c
SRCS+= smbc_prc.c
SRCS+= smbc_prc_param_out.c
SRCS+= smbc_prc_sub.c
SRCS+= smbc_ugp.c
SRCS+= smbc_smbx.c
SRCS+= dynconfig.c

SRCS+= lang_tdb.c

SRCS+= arc4.c
SRCS+= charcnv.c
SRCS+= crc32.c
SRCS+= data_blob.c
SRCS+= debug.c
SRCS+= dmallocmsg.c
SRCS+= dprintf.c
SRCS+= dummyroot.c
SRCS+= dummysmbd.c
SRCS+= events.c
SRCS+= fault.c
SRCS+= gencache.c
SRCS+= genrand.c
SRCS+= hmacmd5.c
SRCS+= iconv.c
SRCS+= interface.c
SRCS+= interfaces.c
SRCS+= ldap_debug_handler.c
SRCS+= md4.c
SRCS+= messages.c
SRCS+= module.c
SRCS+= ms_fnmatch.c
SRCS+= secace.c
SRCS+= secacl.c
SRCS+= secdesc.c
SRCS+= select.c
SRCS+= sharesec.c
SRCS+= signal.c
SRCS+= sock_exec.c
SRCS+= substitute.c
SRCS+= system.c
SRCS+= tallocmsg.c
SRCS+= time.c
SRCS+= username.c
SRCS+= util.c
SRCS+= util_file.c
SRCS+= util_pw.c
SRCS+= util_seaccess.c
SRCS+= util_sec.c
SRCS+= util_sid.c
SRCS+= util_sock.c
SRCS+= util_str.c
SRCS+= util_tdb.c
SRCS+= util_unistr.c
SRCS+= util_uuid.c
SRCS+= version.c
SRCS+= wins_srv.c
SRCS+= xfile.c

SRCS+= replace.c

SRCS+= talloc.c

SRCS+= ads_status.c
SRCS+= dns.c
.if defined(SMBCD_KERBEROS_SUPPORT)
SRCS+= kerberos.c
SRCS+= krb5_errs.c
.endif

SRCS+= asn1.c
SRCS+= cliconnect.c
SRCS+= clidfs.c
SRCS+= clientgen.c
SRCS+= clierror.c
SRCS+= clifile.c
SRCS+= clikrb5.c
SRCS+= clilist.c
SRCS+= clioplock.c
SRCS+= clirap.c
SRCS+= clirap2.c
SRCS+= clireadwrite.c
SRCS+= clispnego.c
SRCS+= clistr.c
SRCS+= clitrans.c
SRCS+= conncache.c
SRCS+= credentials.c
SRCS+= dcerpc_err.c
SRCS+= doserr.c
SRCS+= errormap.c
.if !defined(MFP)
SRCS+= namecache.c
.endif
SRCS+= namequery.c
SRCS+= nmblib.c
SRCS+= nterr.c
SRCS+= ntlmssp.c
SRCS+= ntlmssp_parse.c
SRCS+= ntlmssp_sign.c
SRCS+= pwd_cache.c
SRCS+= smb_signing.c
SRCS+= smbdes.c
SRCS+= smbencrypt.c
SRCS+= smberr.c
SRCS+= unexpected.c
SRCS+= loadparm.c
SRCS+= params.c
SRCS+= machine_sid.c
SRCS+= secrets.c
SRCS+= cli_lsarpc.c
SRCS+= cli_pipe.c
SRCS+= cli_netlogon.c
SRCS+= cli_samr.c
SRCS+= cli_srvsvc.c
SRCS+= parse_lsa.c
SRCS+= parse_misc.c
SRCS+= parse_net.c
SRCS+= parse_prs.c
SRCS+= parse_rpc.c
SRCS+= parse_samr.c
SRCS+= parse_sec.c
SRCS+= parse_srv.c
SRCS+= error.c
SRCS+= freelist.c
SRCS+= io.c
SRCS+= lock.c
SRCS+= open.c
SRCS+= tdb.c
SRCS+= transaction.c
SRCS+= traverse.c

NCS_COM_LIB_DIR=${TOPDIR}/gwcommon/libx86

.if defined(SMBCD_KERBEROS_SUPPORT)
LDADD+= -L$(DIR_GWCOMMON)/libx86
LDADD+= -lcom_err -lgssapi -lkrb5 -lasn1 -lvers -lroken -lcrypto
#LDADD+= -L/usr/lib -lcom_err -lgssapi -lkrb5 -lasn1 -lroken -lcrypto
.endif
LDADD+= -L$(NCS_COM_LIB_DIR)
LDADD+= -lmfprintf_nonptl -ltxtenc
LDADD+= -L$(NCS_TOP_LIB_DIR)
#LDADD+= -lsyslog
.if defined(LLMNR)
LDADD+= -L$(NCS_TOP_LIB_DIR)
LDADD+= -lllmnr
.endif
.if defined(WSD)
LDADD+= -L$(NCS_TOP_LIB_DIR)
LDADD+= -lwsd
.endif
LDADD+= -L$(NCS_TOP_LIB_DIR) -lparamapi

LDADD+= -lncssignal
LDADD+= -L${TOPDIR}/gwpf_base/destdir/usr/lib -lgwipc_socket
LDADD+= -L/usr/lib -lpthread -lc

all: $(PROG)
	strip -g $(PROG)
	$(INSTALL) $(PROG) $(TOPDIR)/_obj/network/inet/smbcd

clean:
	rm -f $(TOPDIR)/_obj/network/inet/smbcd

LDFLAGS+= -Xlinker "-Map" -Xlinker "smbcd.map"

.include <bsd.prog.mk>

